//
//  RootViewController.m
//  iMoc
//
//  Created by 微我网络 on 15/1/10.
//  Copyright (c) 2015年 lamcelot. All rights reserved.
//

#import "RootViewController.h"
#import "CenterViewController.h"
#import "SideViewController.h"
#import "ShareViewController.h"
#import <MMDrawerVisualState.h>

@interface RootViewController ()

@property (nonatomic,strong) UINavigationController *nav;
@property (nonatomic,strong) CenterViewController *center;
@property (nonatomic,strong) SideViewController *sideVC;


@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    
    if (!_center) {
        _center = [[CenterViewController alloc] init];
        _nav = [[UINavigationController alloc] initWithRootViewController:_center];
        [_nav.navigationBar setTranslucent:YES];
        [_nav.navigationBar setShadowImage:[UIImage new]];
        [_nav.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
        [_nav.navigationBar setTintColor:[UIColor clearColor]];
    }
    if (!_sideVC) {
        _sideVC = [[SideViewController alloc] init];
    }
    [self setCenterViewController:_nav];
    [self setLeftDrawerViewController:_sideVC];
    [self setShowsShadow:YES];
    [self setShouldStretchDrawer:NO];
    [self setMaximumLeftDrawerWidth:100];
    [self setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
    [self setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
    [self setDrawerVisualStateBlock:[MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:3.0]];
    [self initView];
}

- (void)initView
{
    [_sideVC.infoBtn  addTarget:self action:@selector(infoVC) forControlEvents:UIControlEventTouchUpInside];
    [_sideVC.setBtn   addTarget:self action:@selector(setVC) forControlEvents:UIControlEventTouchUpInside];
    [_sideVC.sportBtn addTarget:self action:@selector(userInfo) forControlEvents:UIControlEventTouchUpInside];
}

- (void)infoVC
{
    [self performSegueWithIdentifier:@"pushInfo" sender:self];
    [self closeDrawerAnimated:YES completion:nil];
}

- (void)setVC
{
    [self performSegueWithIdentifier:@"pushSet" sender:self];
    [self closeDrawerAnimated:YES completion:nil];
}

- (void)userInfo {
    
    [self performSegueWithIdentifier:@"pushShare" sender:self];
    [self closeDrawerAnimated:YES completion:nil];
}

- (void)viewWillAppear:(BOOL)animated
{
    self.edgesForExtendedLayout=UIRectEdgeNone;
    self.navigationController.navigationBarHidden = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
